package com.wkq.util.transformer

import android.view.View
import androidx.viewpager2.widget.ViewPager2

/**
 *
 *@Author: wkq
 *
 *@Time: 2025/7/30 10:06
 *
 *@Desc: 水平立体旋转
 */
class CubeInPageTransformer : ViewPager2.PageTransformer {
    override fun transformPage(page: View, position: Float) {
        page.cameraDistance = 20000f

        if (position < -1) {
            page.alpha = 0f
        } else if (position <= 0) { // [-1,0]
            page.alpha = 1f
            page.pivotX = page.width.toFloat()
            page.rotationY = -90 * Math.abs(position)
        } else if (position <= 1) { // (0,1]
            page.alpha = 1f
            page.pivotX = 0f
            page.rotationY = 90 * Math.abs(position)
        } else {
            page.alpha = 0f
        }
    }
}
